#include <ctype.h>
#include <stdio.h>
#include "5.1.1.c"

// ??



int main()
{

  int getint(int *);
  int getfloat(float *);
  int n;
  float array[SIZE];

  //initialize array
  for (int i=0; i<SIZE; i++)
    array[i]=0;
  
  for (n = 0; n < SIZE && getfloat(&array[n]) != EOF; n++)
    {
	 //	 printf("we have an int! \n current array: \n");
	 printf("\n current array: \n");
	 for (int i=0; i<SIZE; i++)
	   printf("\t %d %f \n",i,array[i]);
    }
  //  for (int i=0; i<SIZE; i++)
  //  printf("[%d] : %d \n", i, array[i]);

  printf("\n");
  return 0;
}


   /* getint:  get next integer from input into *pn */
   int getint(int *pn)
   {
       int c, sign;

       while (isspace(c = getch()))   /* skip white space */
           ;
       if (!isdigit(c) && c != EOF && c != '+' && c != '-') {
           ungetch(c);  /* it is not a number */
           return 0;
       }
       sign = (c == '-') ? -1 : 1;
       if (c == '+' || c == '-')
           c = getch();

	  // what if it's not a digit?
	  if (!isdigit(c))
	    {
		 ungetch(c);
		 return getint(pn);
	    }
	  
       for (*pn = 0; isdigit(c) ;)
	    {	 
	     (*pn) = 10 * *pn + (c - '0');
  	     c = getch();
	    }
       *pn *= sign;
       if (c != EOF)
           ungetch(c);
       return c;
   }



   /* getint:  get next integer from input into *pn */
   int getfloat(float *pn)
   {
       int c, sign;

       while (isspace(c = getch()))   /* skip white space */
           ;
       if (!isdigit(c) && c != EOF && c != '+' && c != '-') {
           ungetch(c);  /* it is not a number */
           return 0;
       }
       sign = (c == '-') ? -1 : 1;
       if (c == '+' || c == '-')
           c = getch();

	  // what if it's not a digit?
	  if (!isdigit(c))
	    {
		 ungetch(c);
		 return getfloat(pn);
	    }
	  
       for (*pn = 0; isdigit(c) ;)
	    {	 
	     (*pn) = 10 * *pn + (c - '0');
  	     c = getch();
	    }

	  if (c=='.')
	    {
 		 c=getch(); //get thing AFTER the .
		 for (int d = 0; isdigit(c) ; d++)
		   {
			float nextfloat= (c - '0');
			for (int e=0; e<=d; e++)
			   nextfloat/=10;
			(*pn) = (*pn) + nextfloat;
			c = getch();
		   }
	    }

       *pn *= sign;
       if (c != EOF)
           ungetch(c);
       return c;
   }

